package com.sangsang.kafka.domain.dto;

import com.alibaba.fastjson.annotation.JSONField;

import java.util.Objects;


/**
 * T: 具体的实体类
 *
 * @author liutangqi
 * @date 2023/12/21 18:19
 */
public class PayloadDto<T> {

    /**
     * 变化前的数据
     */
    private T before;
    /**
     * 变化后的数据
     */
    private T after;

    /**
     * 源数据信息，包含binlog文件名和具体位置
     */
    private SourceDto source;

    /**
     * 操作类型
     */
    private String op;

    /**
     * 操作时间
     */
    @JSONField(name = "ts_ms")
    private Long ts_ms;


    private Object transaction;


    public PayloadDto() {
    }

    public T getBefore() {
        return this.before;
    }

    public T getAfter() {
        return this.after;
    }

    public SourceDto getSource() {
        return this.source;
    }

    public String getOp() {
        return this.op;
    }

    public Long getTs_ms() {
        return this.ts_ms;
    }

    public Object getTransaction() {
        return this.transaction;
    }

    public void setBefore(T before) {
        this.before = before;
    }

    public void setAfter(T after) {
        this.after = after;
    }

    public void setSource(SourceDto source) {
        this.source = source;
    }

    public void setOp(String op) {
        this.op = op;
    }

    public void setTs_ms(Long ts_ms) {
        this.ts_ms = ts_ms;
    }

    public void setTransaction(Object transaction) {
        this.transaction = transaction;
    }

    @Override
    public boolean equals(Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof PayloadDto)) {
            return false;
        } else {
            PayloadDto<?> other = (PayloadDto) o;
            if (!other.canEqual(this)) {
                return false;
            } else {
                Object this$ts_ms = this.getTs_ms();
                Object other$ts_ms = other.getTs_ms();
                if (this$ts_ms == null) {
                    if (other$ts_ms != null) {
                        return false;
                    }
                } else if (!this$ts_ms.equals(other$ts_ms)) {
                    return false;
                }

                Object this$before = this.getBefore();
                Object other$before = other.getBefore();
                if (this$before == null) {
                    if (other$before != null) {
                        return false;
                    }
                } else if (!this$before.equals(other$before)) {
                    return false;
                }

                Object this$after = this.getAfter();
                Object other$after = other.getAfter();
                if (this$after == null) {
                    if (other$after != null) {
                        return false;
                    }
                } else if (!this$after.equals(other$after)) {
                    return false;
                }

                label62:
                {
                    Object this$source = this.getSource();
                    Object other$source = other.getSource();
                    if (this$source == null) {
                        if (other$source == null) {
                            break label62;
                        }
                    } else if (this$source.equals(other$source)) {
                        break label62;
                    }

                    return false;
                }

                label55:
                {
                    Object this$op = this.getOp();
                    Object other$op = other.getOp();
                    if (this$op == null) {
                        if (other$op == null) {
                            break label55;
                        }
                    } else if (this$op.equals(other$op)) {
                        break label55;
                    }

                    return false;
                }

                Object this$transaction = this.getTransaction();
                Object other$transaction = other.getTransaction();
                if (this$transaction == null) {
                    if (other$transaction != null) {
                        return false;
                    }
                } else if (!this$transaction.equals(other$transaction)) {
                    return false;
                }

                return true;
            }
        }
    }

    protected boolean canEqual(Object other) {
        return other instanceof PayloadDto;
    }

    @Override
    public int hashCode() {
        return Objects.hash(before, after, source, op, ts_ms, transaction);
    }

    @Override
    public String toString() {
        return "PayloadDto(before=" + this.getBefore() + ", after=" + this.getAfter() + ", source=" + this.getSource() + ", op=" + this.getOp() + ", ts_ms=" + this.getTs_ms() + ", transaction=" + this.getTransaction() + ")";
    }

}
